package com.controller;


import com.github.pagehelper.PageInfo;
import com.pojo.Siteids;
import com.pojo.Siteproject;
import com.service.SiteService;
import com.vo.Result;
import com.vo.SiteDetailVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/Site")
public class SiteDetailController {
    @Resource
    private SiteService siteService;

    @RequestMapping("/Detail/index")
    public String toSite(){
        return "/Site/SiteDetail";
    }

    @RequestMapping("/Detail/show")
    @ResponseBody
    public Result selectSite(@RequestBody SiteDetailVo detailVo){

        siteService.deleteselectmingxiids();

        List<Integer> selectprojectids = siteService.selectprojectids();
        for (Integer selectprojectid : selectprojectids) {
            Siteproject selectsiteprojectbyidsthree = siteService.selectsiteprojectbyidsthree(selectprojectid);

            Siteids siteids=new Siteids();

            siteids.setProjectid(selectsiteprojectbyidsthree.getId());
            siteids.setRouteid(selectsiteprojectbyidsthree.getRouteid());

            List<Integer> selectpointidbyrouteid = siteService.selectpointidbyrouteid(selectsiteprojectbyidsthree.getRouteid());

            for (Integer integer : selectpointidbyrouteid) {
                siteids.setPointid(integer);

                siteService.addsiteids(siteids);
            }
        }



        PageInfo<Siteids> selectsiteids = siteService.selectsiteids(detailVo);
        return Result.success(selectsiteids);
    }

}
